package io.github.ali.commons.bean;

/**
 * @author ALi
 * @version 1.0
 * @date 2023-04-21 17:37
 * @description
 */
public class MemoryParameter<T> extends Parameter<T> {
    private T value;

    protected MemoryParameter(String name, T defaultValue) {
        super(name, defaultValue);
    }

    @Override
    public boolean doesExist() {
        return value != null;
    }

    @Override
    protected void save(T value) {
        this.value = value;
    }

    @Override
    public T getValue(T defaultValue) {
        return this.value == null ? defaultValue : this.value;
    }
}
